package com.nf.handlers;

import com.nf.Constants;
import com.nf.MiniResultSetHandler;
import com.nf.MiniRowProcessor;
import org.apache.commons.dbutils.RowProcessor;
import org.apache.commons.dbutils.handlers.ArrayHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;

/**
 * 　　* @description: TODO
 * 　　* @param
 * 　　* @return
 * 　　* @throws
 * 　　* @author Administrator
 * 　　* @date $ $
 *
 */
public class MiniMapHandler implements MiniResultSetHandler<Map<String,Object>> {
    private final MiniRowProcessor convert;

    public MiniMapHandler() {
        this(Constants.DEFAULT_ROW_PROCESSOR);
    }

    public MiniMapHandler(MiniRowProcessor convert) {
        super();
        this.convert = convert;
    }

    @Override
    public Map<String, Object> handle(ResultSet resultSet) throws SQLException {
        return resultSet.next() ? this.convert.toMap(resultSet) : null;
    }
}
